package com.company;

import com.utils.FileUtilsForLinkList;
import com.utils.MyLinkList;

import java.io.IOException;

public class SortLink {


    /**
     * 快速排序
     * @throws IOException
     */
    public void quickSortLink() throws IOException {
        FileUtilsForLinkList fufl = new FileUtilsForLinkList();
        fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        MyLinkList maps = fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        maps.quickSort();
        maps.toString();
        System.out.println("总共"+ maps.getSize() + "条！！");
    }

    /**
     * 选择排序
     * @throws IOException
     */
    public void selectSortLink() throws IOException {

        FileUtilsForLinkList fufl = new FileUtilsForLinkList();
        fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        MyLinkList maps = fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        maps.selectSort();
        maps.toString();
        System.out.println("总共"+ maps.getSize() + "条！！");
    }

    /**
     * 冒泡排序
     * @throws IOException
     */
    public void BublleSort() throws IOException {

        FileUtilsForLinkList fufl = new FileUtilsForLinkList();
        fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        MyLinkList maps = fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        maps.bubbleSortOfID();

        maps.toString();

        System.out.println("总共"+ maps.getSize() + "条！！");
    }

    /**
     * 插入排序
     * @throws IOException
     */
    public void insertSort() throws IOException {

        FileUtilsForLinkList fufl = new FileUtilsForLinkList();
        fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        MyLinkList maps = fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        maps.insertionSortList();

        maps.toString();

        System.out.println("总共"+ maps.getSize() + "条！！");
    }

    /**
     * 归并排序
     * @throws IOException
     */
    public void mergeSort() throws IOException {

        FileUtilsForLinkList fufl = new FileUtilsForLinkList();
        fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");

        MyLinkList maps = fufl.readFile("src\\com\\data\\ORDER_SAVE.txt");


        maps.mergeSortList();

        maps.toString();

        System.out.println("总共"+ maps.getSize() + "条！！");
    }


}
